<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1">
    <meta property="qc:admins" content="02572225676711142106375" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <title>哇吖自由行</title>
    <meta property="wb:webmaster" content="3237ac6d9ca40c08" />
    <link rel="stylesheet" href="<{$smarty.const._CDN_}>/resource/www/css/style.css?<{$versionCode}>">
    <link rel="shortcut icon" type="image/x-icon" href="/resource/www/imgs/browser-tab-logo.png">

    <script src="<{$smarty.const._CDN_}>/resource/www/js/jquery-2.1.4.min.js"></script>
    <script src="<{$smarty.const._CDN_}>/resource/laydate/laydate<{$laydate_version}>.js"></script>
    <script src="<{$smarty.const._CDN_}>/resource/layer/layer.js"></script>
    <script src="<{$smarty.const._CDN_}>/resource/www/js/common.js"></script>
    <script src="<{$smarty.const._CDN_}>/resource/www/js/share.js"></script>
    <script>
        function flush_code(){
            $(".i-code").attr('src','/checkcode?'+new Date().getTime());
        }

        function flush_register_code(){
            $('.scode').attr('src','/checkcode?'+new Date().getTime());
        }

        function valid_email(email){
            var url = '/valid_email/'+email;
            $.get(url,function(o) {
                if(o.status){
                    return false;
                }
            });
        }

    </script>
    <script>
        $(document).ready(function () {
            laydate.skin('<{$laydate_skin}>');
            layer.config (
                    {
                        extend : 'extend/layer.ext.js'
                    }
            );

            // 游客注册， 导游注册切换效果
            if (document.getElementById('register-wrap')) {
                lw.tabSwitch(document.getElementById('register-wrap'), 'li', 'reg-tab', 'li');

            }

            // 游客登陆， 导游登陆切换效果
            if (document.getElementById('login-wrap')) {
                lw.tabSwitch(document.getElementById('login-wrap'), 'li', 'login-tab', 'li');
            }

        });

        function tips_ajax_message (method, url, data)
        {
            var index = layer.load(0);

            if (! method) method = 'GET';

            if (method == 'GET')
            {
                $.get(url, function (o) {
                    layer.close(index);
                    if (o.message)
                        layer.msg(o.message);
                    else
                        layer.msg('系统错误，请重试');
                }, 'json');
            }
            else
            {
                $.post(url, data, function (o) {
                    layer.close(index);
                    if (o.message)
                        layer.msg(o.message);
                    else
                        layer.msg('系统错误，请重试');
                }, 'json');
            }
        }

        function showBox(obj1, obj2) {
            $(obj1).show();
            $(obj2).show();
        }

        function hideBox(obj1, obj2) {
            $(obj1).hide();
            $(obj2).hide();
        }

        function change_box(obj1, obj2) {
            $(obj1).hide();
            $(obj2).show();
        }

        function showXiala(item) {

            $(item).parent().find('.xiala').show();

            $(item).parent().find('.li').each(function() {

                $(this).on('click',function() {
                    $(item).val($(this).val());
                    $(item).parent().find('.xiala').hide();
                    return false;
                });

            });

        }

        function submit_visitor_reg() {

            var oVisitorReg = $('#register-wrap').find('.visitor');
            var oVisitorMailReg = $('#register-wrap .visitor').find('div.visitor-mail-reg');
            var oVisitorPhoneReg = $('#register-wrap .visitor').find('div.visitor-phone-reg');
           
            oVisitorReg.find('.error').removeClass('error');

            if (!oVisitorReg.find('.checkbox').is(':checked')) {
                layer.msg('请勾选同意协议规则');
                return false;
            }

            if(!oVisitorMailReg.is(":hidden") && oVisitorPhoneReg.is(":hidden")){
            var oEmailVal = $.trim(oVisitorMailReg.find('.email').val());
            if (!oEmailVal) {
                layer.msg('电子邮件地址不能为空');
                oVisitorMailReg.find('.email').addClass('error');
                return false;
            }
            var oEmailReg = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/;
            if (!oEmailReg.test(oEmailVal)) {
                layer.msg('请输入正确的邮件地址');
                oVisitorMailReg.find('.email').addClass('error');
                return false;
            }
            var oPasswordVal = oVisitorMailReg.find('.shuru-psd').val();
            if (!oPasswordVal) {
                layer.msg('请输入密码');
                oVisitorMailReg.find('.shuru-psd').addClass('error');
                return false;
            }
            var oAgainPasswordVal = oVisitorMailReg.find('.queren-psd').val();
            if (!oAgainPasswordVal) {
                layer.msg('请再次输入密码');
                oVisitorMailReg.find('.queren-psd').addClass('error');
                return false;
            }
            if (oPasswordVal != oAgainPasswordVal) {
                layer.msg('两次输入密码不一致');
                oVisitorMailReg.find('.queren-psd').addClass('error');
                return false;
            }
            var oCode = $.trim(oVisitorMailReg.find('.code').val());
            if (!oCode) {
                layer.msg('请输入验证码');
                oVisitorMailReg.find('.code').addClass('error');
                return false;
            }

            $.post('/user/tourist_reg', {
                email : oEmailVal,
                code  : oCode,
                password : oPasswordVal,
                type : 'tourist',
                way : 'mail'
            }, function (o) {
                switch(o.status)
               {
                  case 0:
                  window.location.href("/homepage/regok?url="+o.url);
                  break;
                  /* 验证码错误 */
                  case 1:
                  $('#register-wrap .visitor .scode').attr('src','/checkcode?'+new Date().getTime());
                  layer.msg(o.errormsg);
                  $('#register-wrap .visitor .code').addClass('error');
                  break;
                  /* 邮箱已存在 */
                  case 2:
                  $('#register-wrap .visitor .scode').attr('src','/checkcode?'+new Date().getTime());
                  layer.msg(o.errormsg);
                  $('#register-wrap .visitor .email').addClass('error');
                  break; 
                  /* 系统错误 */
                  case 5:
                  $('#register-wrap .visitor .scode').attr('src','/checkcode?'+new Date().getTime());
                  layer.msg(o.errormsg);
                  break;
                } 
            }, 'json');
            
            }

           if(oVisitorMailReg.is(":hidden") && !oVisitorPhoneReg.is(":hidden")){
            	var num_visitor = $.trim(oVisitorPhoneReg.find("#num_visitor").val());
                if (!num_visitor) {
                    layer.msg("手机号码不能为空");
                    oVisitorPhoneReg.find("#num_visitor").addClass('error');
                    return false;
                }
                var numReg=/^[1-9][0-9]+$/;
                if(!numReg.test(num_visitor)){
                    layer.msg("手机号码格式不正确");
                    oVisitorPhoneReg.find("#num_visitor").addClass('error');
                    return false;
                }

                var oMessCode = $.trim(oVisitorPhoneReg.find('.sms_code_visitor').val());
                if (!oMessCode) {
                    layer.msg("请输入短信验证码");
                    oVisitorPhoneReg.find('.sms_code_visitor').addClass('error');
                    return false;
                }
                var oPasswordVal = oVisitorPhoneReg.find('.shuru-psd').val();
                if (!oPasswordVal) {
                    layer.msg("请输入密码");
                    oVisitorPhoneReg.find('.shuru-psd').addClass('error');
                    return false;
                }
                var oAgainPasswordVal = oVisitorPhoneReg.find('.queren-psd').val();
                if (!oAgainPasswordVal) {
                     layer.msg("请再次输入密码");
                     oVisitorPhoneReg.find('.queren-psd').addClass('error');
                    return false;
                }
                if (oPasswordVal != oAgainPasswordVal) {
                     layer.msg("两次输入密码不一致");
                     oVisitorPhoneReg.find('.queren-psd').addClass('error')
                     return false;
                }
                var oCode = $.trim(oVisitorPhoneReg.find('.code').val());
                if (!oCode) {
                    layer.msg("请输入验证码");
                    oVisitorPhoneReg.find('.code').addClass('error');
                    return false;
                }
                $.post('/user/tourist_reg', {
                    num : num_visitor,
                    areacode : $("#areacode_visitor").val(),
                    code : oCode,
                    sms_code : oMessCode,
                    password : oPasswordVal,
                    type : 'tourist',
                    way : 'phone'
                }, function (o) {
                    switch(o.status)
                   {
                      case 0:
                      window.location.href("/homepage/tourist_phone_reg_confirm");
                      break;
                      /* 验证码错误 */
                      case 1:
                      $('#register-wrap .visitor .scode').attr('src','/checkcode?'+new Date().getTime());
                      layer.msg(o.errormsg);
                      $('#register-wrap .visitor .code').addClass('error');
                      break;
                      /* 短信验证码错误 */
                      case 3:
                      $('#register-wrap .visitor .scode').attr('src','/checkcode?'+new Date().getTime());
                      layer.msg(o.errormsg);
                      $('#register-wrap .visitor .sms_code_visitor').addClass('error');
                      break;
                      /* 手机已存在 */
                      case 4:
                      $('#register-wrap .visitor .scode').attr('src','/checkcode?'+new Date().getTime());
                      layer.msg(o.errormsg);
                      $('#register-wrap .visitor #num_visitor').addClass('error'); 
                      break;
                      /* 系统错误 */
                      case 5:
                      $('#register-wrap .visitor .scode').attr('src','/checkcode?'+new Date().getTime());
                      layer.msg(o.errormsg);
                      break;
                    }
                }, 'json');

            }
            
            return false;
        }

        function enter_submit_visitor_reg() {
            submit_visitor_reg();
        }

        function submit_guide_reg() {

            var oGuideReg = $('#register-wrap').find('.guide');
            var sex = $('input:radio[name="sex"]:checked').val();

            oGuideReg.find('.error').removeClass('error');

            var oXing = $.trim(oGuideReg.find('.xing').val());
            if (!oXing) {
                layer.msg('请输入姓氏');
                oGuideReg.find('.xing').addClass('error');
                return false;
            }
            var oMing = $.trim(oGuideReg.find('.ming').val());
            if (!oMing) {
                layer.msg('请输入名字');
                oGuideReg.find('.ming').addClass('error');
                return false;
            }
            var oEmailVal = $.trim(oGuideReg.find('.email').val());
            if (!oEmailVal) {
                layer.msg('电子邮件地址不能为空');
                oGuideReg.find('.email').addClass('error');
                return false;
            }
            var oEmailReg = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/;
            if (!oEmailReg.test(oEmailVal)) {
                layer.msg('请输入正确的邮件地址');
                oGuideReg.find('.email').addClass('error');
                return false;
            }
            var oPasswordVal = oGuideReg.find('.shuru-psd').val();
            if (!oPasswordVal) {
                layer.msg('请输入密码');
                oGuideReg.find('.shuru-psd').addClass('error');
                return false;
            }
            var oAgainPasswordVal = oGuideReg.find('.queren-psd').val();
            if (!oAgainPasswordVal) {
                layer.msg('请再次输入密码');
                oGuideReg.find('.queren-psd').addClass('error');
                return false;
            }
            if (oPasswordVal != oAgainPasswordVal) {
                layer.msg('两次输入密码不一致');
                oGuideReg.find('.queren-psd').addClass('error');
                return false;
            }

            var num = $.trim(oGuideReg.find("#num").val());
            if (!$.trim(num)) {
                layer.msg("手机号码不能为空");
                oGuideReg.find("#num").addClass('error');
                return false;
            }
             
            var numReg=/^[1-9][0-9]+$/;
            if(!numReg.test(num)){
                layer.msg("手机号码格式不正确");
                oGuideReg.find("#num").addClass('error');
                return false;
            }
               
             
            var oMessCode = $.trim(oGuideReg.find('.sms_code').val());
            if (!oMessCode) {
                layer.msg('请输入短信验证码');
                oGuideReg.find('.sms_code').addClass('error');
                return false;
            }

            var oCode = $.trim(oGuideReg.find('.code').val());
            if (!oCode) {
                layer.msg('请输入验证码');
                oGuideReg.find('.code').addClass('error');
                return false;
            }
            if (!oGuideReg.find('.checkbox').is(':checked')) {
                layer.msg('请同意协议规则');
                return false;
            }

            $.post('/user/guider_reg', {
                email : oEmailVal,
                ming : oMing,
                xing : oXing,
                code  : oCode,
                gender  : sex,
                password : oPasswordVal,
                num : $("#num").val(),
                areacode : $("#areacode").val(),
                sms_code : $("#sms_code").val(),
                type : 'guider'
            }, function (o) {
                switch(o.status)
               {
                  case 0:
                  window.location.href("/homepage/tourist_phone_reg_confirm");
                  break;
                  /* 验证码错误 */
                  case 1:
                  $('#register-wrap .guide .scode').attr('src','/checkcode?'+new Date().getTime());
                  layer.msg(o.errormsg);
                  $('#register-wrap .guide .code').addClass('error');
                  break;
                  /* 邮箱已存在 */
                  case 2:
                  $('#register-wrap .guide .scode').attr('src','/checkcode?'+new Date().getTime());
                  layer.msg(o.errormsg);
                  $('#register-wrap .guide .email').addClass('error');
                  break; 
                  /* 短信验证码错误 */
                  case 3:
                  $('#register-wrap .guide .scode').attr('src','/checkcode?'+new Date().getTime());
                  layer.msg(o.errormsg);
                  $('#register-wrap .guide .sms_code').addClass('error');
                  break;
                  /* 手机已存在 */
                  case 4:
                  $('#register-wrap .guide .scode').attr('src','/checkcode?'+new Date().getTime());
                  layer.msg(o.errormsg);
                  $('#register-wrap .guide #num').addClass('error'); 
                  break;
                  /* 系统错误 */
                  case 5:
                  $('#register-wrap .guide .scode').attr('src','/checkcode?'+new Date().getTime());
                  layer.msg(o.errormsg);
                  break;
                  }
            }, 'json');

            return false;
        }

        function enter_submit_guide_reg() {
            submit_guide_reg();
        }

        function submit_login(item,type) {
            var oLoginReg = $(item);
            var oPrompt = oLoginReg.find('.prompt');
            var oEmailVal = $.trim(oLoginReg.find('.email').val());
            oPrompt.hide();

            if (!oEmailVal) {
                oPrompt.show().html('邮箱地址/手机号码不能为空');
                return false;
            }

            var oEmailReg = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/;
            var oPhoneReg = /^[1-9][0-9]+$/;
            if (!oEmailReg.test(oEmailVal.trim()) && !oPhoneReg.test(oEmailVal.trim())) {
                oPrompt.show().html('请输入正确的邮箱或是手机号码');
                return false;
            }
            var oPasswordVal = oLoginReg.find('.shuru-psd').val();
            if (!oPasswordVal) {
                oPrompt.show().html('请输入密码');
                return false;
            }

//            var oCode = oLoginReg.find('.code').val();
//            if (!oCode) {
//                oPrompt.show().html('请输入验证码');
//                return false;
//            }

            $.post('/user/login', {
                email : oEmailVal,
                utype  : type,
                password : oPasswordVal
            }, function (o) {
                if (o.status == 0)
                {
                    window.location.reload();
                }
                else if(o.status == 2){

                    var html = "<a href='javascript:;' onclick='send_email(\""+type+"\")'>点击</a>"+"重新发送邮件";
                    oPrompt.show().html(o.errormsg + " " + html);
                }
                else
                {
                   /* var img = $(".i-code");
                    img.attr('src','/checkcode?'+new Date().getTime());*/
                    oPrompt.show().html(o.errormsg);


                }
            }, 'json');

            return false;
        }

        function enter_submit_login() {
            submit_login(item);
        }

        function shensu(){
            layer.open({
                type: 1,
                title : false,
                skin: 'layui-layer-demo', //样式类名
                shift: 2,
                content: $('#shensu'),
                area: ['340px', '150px'],
            });
        }

    </script>
</head>

<body style="background: #f5f5f5;">
<{if $global_user.userUid <= 0}>
    <{include file="www/login.tpl"}>
<{/if}>
